import request from "@/utils/request";
import Url from "./apiUrlConfig";

/**
 * @param {string} url
 * @param {string} get | post
 * @param {Object} option
 */
export function queryData({ url, method, option = {} }) {
  let newOption = {};

  Object.assign(newOption, option);

  try {
    // 发送 POST 请求
    return request({
      method: method ? method : "get",
      url: Url[url],
      data: newOption
    });
  } catch (error) {
    console.error("请求异常", error);
  }
}
